package net.lijingye.education.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import net.lijingye.education.entity.SourceReply;
import net.lijingye.education.util.CommonUtil;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by LijingYe on 2016/3/26.
 */
public class SourceReplyVO {
    @JSONField(name = "id", ordinal = 0, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String id;
    @JSONField(name = "time", ordinal = 1, serialzeFeatures = SerializerFeature.WriteMapNullValue, format = "yyyy/MM/dd HH:mm")
    private Date time;
    @JSONField(name = "userId", ordinal = 2, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String userId;
    @JSONField(name = "userName", ordinal = 3, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String userName;
    @JSONField(name = "userFaceIcon", ordinal = 4, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String userFaceIcon;
    @JSONField(name = "content", ordinal = 5, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String content;
    @JSONField(name = "file", ordinal = 6, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private List<String> file;

    public SourceReplyVO(SourceReply sourceReply) {
        this.id = String.valueOf(sourceReply.getId());
        this.time = sourceReply.getTime();
        this.userId = sourceReply.getUser().getId();
        this.userName = CommonUtil.getUserDisplayName(sourceReply.getUser());
        this.userFaceIcon = sourceReply.getUser().getFaceIcon();
        this.content = sourceReply.getContent();
        this.file = new ArrayList<>();
        sourceReply.getSourceReplyFileList().forEach(sourceReplyFile -> {
            this.file.add(sourceReplyFile.getPath());
        });
    }

    public SourceReplyVO(String id, Date time, String userId, String userName, String userFaceIcon, String content, List<String> file) {
        this.id = id;
        this.time = time;
        this.userId = userId;
        this.userName = userName;
        this.userFaceIcon = userFaceIcon;
        this.content = content;
        this.file = file;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserFaceIcon() {
        return userFaceIcon;
    }

    public void setUserFaceIcon(String userFaceIcon) {
        this.userFaceIcon = userFaceIcon;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public List<String> getFile() {
        return file;
    }

    public void setFile(List<String> file) {
        this.file = file;
    }

    @Override
    public String toString() {
        return "SourceReplyVO{" +
                "id='" + id + '\'' +
                ", time=" + time +
                ", userId='" + userId + '\'' +
                ", userName='" + userName + '\'' +
                ", userFaceIcon='" + userFaceIcon + '\'' +
                ", content='" + content + '\'' +
                ", file=" + file +
                '}';
    }
}
